package com.guanyong.www.controllers.api;

import com.guanyong.model.*;
import com.guanyong.services.KeybaseDetailsService;
import com.guanyong.services.KeybaseJavaService;
import com.guanyong.utils.Comm.ResultCode;
import com.guanyong.utils.Comm.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by mxk on 2017/7/16.
 */
@RestController
@RequestMapping("/api/keybaseJava/")
public class keybaseJavaApi {

    @Autowired
    KeybaseJavaService keybaseJavaService;



    @RequestMapping(value = "delzhishu", method = RequestMethod.GET)
    public ResultObject<Integer> delzhishu(@RequestParam int id){
        ResultObject<Integer> resultObject=new ResultObject<Integer>();
        resultObject= keybaseJavaService.delById(id);
        return resultObject;
    }


    @RequestMapping(value = "upzhishu", method = RequestMethod.GET)
    public ResultObject<Integer> upzhishu(@RequestParam int id,
                                          @RequestParam int baiduNum,
                                          @RequestParam int lookNum,
                                          @RequestParam int weixinNum,
                                          @RequestParam String date,
                                          @RequestParam int day){
        ResultObject<Integer> resultObject=new ResultObject<Integer>();

        KeyJavaZhishuModel keyJavaZhishuModel= new KeyJavaZhishuModel();
        keyJavaZhishuModel.setId(id);
        keyJavaZhishuModel.setBaiduNum(baiduNum);
        keyJavaZhishuModel.setLookNum(lookNum);
        keyJavaZhishuModel.setWeixinNum(weixinNum);
        keyJavaZhishuModel.setCurDate(day);
        keyJavaZhishuModel.setCreateDate(date);
        resultObject= keybaseJavaService.updateById(keyJavaZhishuModel);
        return resultObject;
    }

    @RequestMapping(value = "addzhishu", method = RequestMethod.POST)
    public ResultObject<Integer> addzhishu(
                                          @RequestParam int baiduNum,
                                          @RequestParam int lookNum,
                                          @RequestParam int weixinNum,
                                          @RequestParam int baseid,
                                          @RequestParam String date,
                                          @RequestParam int day){
        ResultObject<Integer> resultObject=new ResultObject<Integer>();

        KeyJavaZhishuModel keyJavaZhishuModel= new KeyJavaZhishuModel();
        keyJavaZhishuModel.setCreateDate(date);
        keyJavaZhishuModel.setBaseId(baseid);
        keyJavaZhishuModel.setBaiduNum(baiduNum);
        keyJavaZhishuModel.setLookNum(lookNum);
        keyJavaZhishuModel.setWeixinNum(weixinNum);
        keyJavaZhishuModel.setCurDate(day);
        resultObject= keybaseJavaService.AddZhishu(keyJavaZhishuModel);
        return resultObject;
    }


    @RequestMapping(value = "zhishulist", method = RequestMethod.GET)
    public ResultObject<List<KeyJavaZhishuModel>> zhishulist(){
        ResultObject<List<KeyJavaZhishuModel>> resultObject=new ResultObject<List<KeyJavaZhishuModel>>();
        resultObject.setResult(keybaseJavaService.getZhishuAll());

        return resultObject;
    }



}
